<%@ taglib prefix="t" tagdir="/WEB-INF/tags"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags"%>
<t:wrapper title="${title} ${topic.title}">
	<jsp:body>
		<div id="navigation">
			<a href="javascript:history.back()">&laquo; <spring:message
					code="content.general.back" /></a>
			<button style="margin: 0 5px; margin-left: 0;"
				onclick="location.href='<c:url value="/course/${course.id}/forum/new_topic"/>'">
				<spring:message code="forum.button.new_topic" />
			</button>
			<c:choose>
				<c:when test="${user.id eq topic.owner.id}">
					<button
						onclick="location.href='<c:url value="/course/${course.id}/forum/${topic.id}/edit"/>'">
						<spring:message code="forum.button.edit_topic" />
					</button>
				</c:when>
			</c:choose>
		</div>
		<table width="100%">
			<c:forEach items="${posts}" var="post">
				<tr height="30px">
					<td><c:out value="${post.owner.firstName}" /> <c:out
							value="${post.owner.lastName}" /></td>
					<td><c:out value="${post.text}" /></td>
					<c:choose>
						<c:when test="${user.id eq post.owner.id}">
							<td><button
									onclick="location.href='<c:url value="/course/${course.id}/forum/${topic.id}/${post.id}/edit"/>'">
									<spring:message code="forum.button.edit_post" />
								</button></td>
						</c:when>
					</c:choose>
				</tr>
			</c:forEach>
		</table>
		<button
			onclick="location.href='<c:url value="/course/${course.id}/forum/${topic.id}/new_post"/>'">
			<spring:message code="forum.button.new_post" />
		</button>
	</jsp:body>
</t:wrapper>